﻿unit FormAppMain;

interface

uses
  SysUtils, Variants, Classes,TJBSControl,qstring,
  Vcl.Graphics,Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
  Vcl.Menus, bsSkinMenus, Vcl.ComCtrls, bsSkinTabs, bsSkinCtrls,
  BusinessSkinForm, bsSkinData;

type
  TFMAppMain = class(TForm)
    bsBusinessSkinForm1: TbsBusinessSkinForm;
    bsSkinPanel1: TbsSkinPanel;
    bsSkinPanel2: TbsSkinPanel;
    bsSkinPageControl1: TbsSkinPageControl;
    bsSkinTabSheet1: TbsSkinTabSheet;
    bsSkinPopupMenu1: TbsSkinPopupMenu;
    ShowFun: TMenuItem;
    ExitFun: TMenuItem;
    TrayIcon1: TTrayIcon;
    bsSkinData1: TbsSkinData;
    bsCompressedStoredSkin1: TbsCompressedStoredSkin;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure ExitFunClick(Sender: TObject);
    procedure ShowFunClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);

  private
//    FTitle      :   string;
    FClose      :   Boolean;
    procedure   DisTrayIcon;
    procedure   DisMainForm;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMAppMain: TFMAppMain;

implementation

uses
  TJ.FMX.FileOper,
  WsScfModuleUnit;

{$R *.dfm}


procedure TFMAppMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
    if not FClose then
    begin
      CanClose :=  False;
      DisTrayIcon;
    end
end;

procedure TFMAppMain.FormCreate(Sender: TObject);
var
  path    :   string;
begin
//  InitAppDir;
  path := GetCurrentDir;

  InitGlobalSkinData(Self, bsSkinData1);
  InitBsControl(bsSkinData1, Self);
  InitControlSkin(Self,'SkinData',GetGlobalSkinDate);

  DataModule2 :=  TDataModule2.Create(nil);
  DataModule2.RegisetSign(0);

//    GetDay
//  FTitle :=  LocalXdataInter.GetAppTitle;
//  Caption := FTitle+'v'+TJGetFileVersion(Application.ExeName);
  FClose := False;
  TrayIcon1.BalloonTitle:=  TsGetFileNameWithoutExtension(Application.ExeName); //'ThinkSign Server';
  TrayIcon1.ShowBalloonHint;
  Application.ShowMainForm:=False;
end;

procedure TFMAppMain.FormDestroy(Sender: TObject);
begin
//
  FreeAndNil(DataModule2);
end;

procedure TFMAppMain.ShowFunClick(Sender: TObject);
begin
  DisMainForm;
end;

procedure TFMAppMain.Button1Click(Sender: TObject);
var
  tms     :     TMemoryStream;
begin
  tms := TMemoryStream.Create;
//  tms.Clear;
end;

procedure TFMAppMain.DisMainForm;
begin
  Visible := True;
  TrayIcon1.Visible:=False;
  Application.ShowMainForm:=True;
end;


procedure TFMAppMain.DisTrayIcon;
begin
  Application.ShowMainForm := False;
  Visible := False;
  TrayIcon1.BalloonHint:= datetimetostr(Now) ;
  TrayIcon1.Visible:=True;
end;

procedure TFMAppMain.ExitFunClick(Sender: TObject);
begin
  FClose := True;
  Close;
end;

end.
